<div class="page-header">
    <h1>
        艺人信息列表
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
        </small>
    </h1>
</div>
<div class="row">
    <div class="col-xs-12">
        <table id="dtpList" class="dataTable">
            <tfoot>
            <tr>
                <td colspan="3">本页合计：</td>
                <td>
                    <span name="Coin" class="tooltip-"/>
                </td>
                <td>
                    <span name="Beans" class="tooltip-"/>
                </td>
                <td colspan="8"></td>
            </tr>
            </tfoot>
        </table>
        <div id="dtpList_filter" class="dataTables_filter">
            <div>
                <select id="dtpList_F_SType" class="selectpicker" data-style="btn btn-info btn-sm" data-width="90px">
                    <option value="">模糊查询</option>
                    <option data-divider="true"></option>
                    <option value="User_ID">用户ID</option>
                    <option value="NickName">用户昵称</option>
                    <option value="RealName">真实姓名</option>
                    <option value="Family_ID">公会ID</option>
                    <option value="Email">Email</option>
                    <option value="Phone">手机号</option>
                    <option value="QQ">QQ号</option>
                </select>
                <input id="dtpList_F_SValue" class="fvalue" type="text"/>
                <select id="dtpList_F_DateType">
                    <option value="Create_Date">注册时间</option>
                    <option value="Rating_Date">评级时间</option>
                    <option value="Live_StartTime">最近直播时间</option>
                    <option value="Integral_Date">最近罚分时间</option>
                    <option value="Approve_Date">审核艺人时间</option>
                    <option value="Cover_Date">审核封面时间</option>
                    <option value="ProtectDue_Date">保护到期时间</option>
                    <option value="Live_Stream_LastDate">直播流更新时间</option>
                    <option value="Live_FirstDate">第一次开播时间</option>
                </select>
                <input id="dtpList_F_StartDate" type="text" style="width: 76px;" placeholder="开始时间">
                <label>-</label>
                <input id="dtpList_F_EndDate" type="text" style="width: 76px;" placeholder="结束时间">
                <select id="dtpList_F_SelectDate"></select>
                <label>状态：</label>
                <select id="dtpList_F_Status">
                    <option value="-1" selected="selected">所有</option>
                    <option value="0">正常</option>
                    <option value="1">锁定</option>
                    <option value="2">申请</option>
                    <option value="3">拒绝</option>
                </select>
                <a id="dtpList_F_Advanced"></a>
                <button id="dtpList_F_Btn"></button>
            </div>
            <div>
                <label>性别：</label>
                <select id="dtpList_F_Sex">
                    <option value="-1">所有</option>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select>
                <label>直播模式：</label>
                <select id="dtpList_F_LiveMode">
                    <option value="-1">所有</option>
                    <option value="0">PC模式</option>
                    <option value="11">手机竖屏</option>
                    <option value="12">手机横屏</option>
                </select>
                <label><input id="dtpList_F_Live" type="checkbox"/>&nbsp;是否直播中</label>
                <label><input id="dtpList_F_IsWeekStar" type="checkbox"/>&nbsp;上周周星</label>
                <label><input id="dtpList_F_IsRecommend" type="checkbox"/>&nbsp;推荐</label>
            </div>
        </div>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.min.js"></script>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.bootstrap.min.js"></script>
<script>
    $(function () {
        //region 时间输入框插件
        $('#dtpList_F_StartDate, #dtpList_F_EndDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true
        });
        //endregion
        //region 绑定日期选择框
        $.KOC.Date.Select.Bind({
            eSelect: $('#dtpList_F_SelectDate'),
            eBegin: $('#dtpList_F_StartDate'),
            eEnd: $('#dtpList_F_EndDate')
        });
        //endregion
        //region dtpList
        var _dtpList = $("#dtpList").dataTable({
            'aoColumns': [
                {
                    'sWidth': '75px', 'data': 'User_ID', 'sName': 'User_ID', 'sTitle': 'ID', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserAnchorInfo:' + cellData).text(cellData));
                    }
                },
                {
                    'data': 'NickName', 'sName': 'EXP', 'sTitle': '昵称', 'bSortable': false,
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html('<span class="Level_Anchor_' + rowData.Anchor_Level + '"></span>' + cellData);
                    }
                },
                {
                    'sWidth': '9%', 'data': 'Family_Name', 'sTitle': '公会名称', 'sClass': 'center t-left', 'bSortable': false,
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html($('<a class="tooltip-" data-rel="tooltip" data-original-title="公会ID：' + rowData.Family_ID + '"/>').attr('data-openwindow', ':FamilyInfo:' + rowData.Family_ID).html(cellData));
                    }
                },
                {
                    'sWidth': '8%', 'data': 'Coin', 'sName': 'Coin', 'sTitle': '金币', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="帐户金币价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '9%', 'data': 'Beans', 'sName': 'Beans', 'sTitle': '金豆', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        if (cellData > 0) {
                            $(td).html('<span class="tooltip-" data-rel="tooltip" data-original-title="帐户金豆价值：' + $.KOC.String.ToCurrencyPositiveStr(cellData / 1000) + '">' + cellData + '</span>');
                        }
                    }
                },
                {
                    'sWidth': '55px', 'data': 'Live', 'sName': 'Live', 'sTitle': '直播', 'sClass': 'center',
                    'createdCell': function (td, cellData, rowData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<i class="fa fa-stop-circle bigger-120" data-rel="tooltip" data-original-title="未直播" />');
                                break;
                            case 1:
                                switch (rowData.Live_Mode) {
                                    case 0:
                                        $(td).html('<i class="fa fa-desktop bigger-120" data-rel="tooltip" data-original-title="PC端直播中" />');
                                        break;
                                    case 11:
                                        $(td).html('<i class="fa fa-tablet bigger-120" data-rel="tooltip" data-original-title="手机竖屏直播中" />');
                                        break;
                                    case 12:
                                        $(td).html('<i class="fa fa-laptop bigger-120" data-rel="tooltip" data-original-title="手机横屏直播中" />');
                                        break;
                                    default:
                                        $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                        break;
                                }
                                break;
                            default:
                                $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '110px', 'data': 'Live_Order_No', 'sName': 'Live_Order_No', 'sTitle': '直播单据', 'sClass': 'center t-right',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', cellData).text(cellData));
                    }
                },
                {
                    'sWidth': '80px', 'data': 'IsWeekStar', 'sName': 'IsWeekStar', 'sTitle': '上周周星', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<span class="badge badge-light"></span>');
                                break;
                            case 1:
                                $(td).html('<span class="badge badge-success">是</span>');
                                break;
                            default:
                                $(td).html('<span class="badge badge-default">未知</span>');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '60px', 'data': 'Rating', 'sName': 'Rating', 'sTitle': '评级', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case -1:
                                $(td).html('<span class="badge badge-light">未评</span>');
                                break;
                            case 6:
                                $(td).html('<span class="badge badge-success">无评</span>');
                                break;
                            case 7:
                                $(td).html('<span class="badge badge-primary">C级</span>');
                                break;
                            case 8:
                                $(td).html('<span class="badge badge-purple">B级</span>');
                                break;
                            case 9:
                                $(td).html('<span class="badge badge-warning">A级</span>');
                                break;
                            case 10:
                                $(td).html('<span class="badge badge-danger">S级</span>');
                                break;
                            default:
                                $(td).html('<span class="badge badge-default">未知</span>');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '110px', 'data': 'Rating_Date', 'sName': 'Rating_Date', 'sTitle': '最近评级', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).isValid() ? moment(cellData).format('YY/MM/DD HH:mm') : '');
                    }
                },
                {
                    'sWidth': '80px', 'data': 'Live_StartTime', 'sName': 'Live_StartTime', 'sTitle': '最近直播', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(cellData ? moment(cellData).fromNow() : '');
                    }
                },
                {
                    'sWidth': '110px', 'data': 'Create_Date', 'sName': 'User_ID', 'sTitle': '创建日期', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).isValid() ? moment(cellData).format('YY/MM/DD HH:mm') : '');
                    }
                },
                {
                    'sWidth': '65px', 'data': 'Status', 'sName': 'Status', 'sTitle': '状态', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<span class="label label-success">正常</span>');
                                break;
                            case 1:
                                $(td).html('<span class="label label-danger">锁定</span>');
                                break;
                            case 2:
                                $(td).html('<span class="label label-warning">申请</span>');
                                break;
                            case 3:
                                $(td).html('<span class="label label-grey">拒绝</span>');
                                break;
                            default:
                                $(td).html('<span class="label label-default">未知</span>');
                                break;
                        }
                    }
                }
            ],
            'aaSorting': [0, 'desc'],
            'sAjaxSource': '/ajax/user.page.useranchor',
            'fnServerParams': function (aoData) {
                if (!this.arrPageFilter) {
                    this.arrPageFilter = {
                        F_DateType: $(this.selector + '_F_DateType').val(),
                        F_StartDate: $(this.selector + '_F_StartDate').val(),
                        F_EndDate: $(this.selector + '_F_EndDate').val(),
                        F_Sex: $(this.selector + '_F_Sex').val(),
                        F_LiveMode: $(this.selector + '_F_LiveMode').val(),
                        F_IsWeekStar: $(this.selector + '_F_IsWeekStar').is(':checked') ? 1 : -1,
                        F_IsRecommend: $(this.selector + '_F_IsRecommend').is(':checked') ? 1 : -1,
                        F_Live: $(this.selector + '_F_Live').is(':checked') ? 1 : -1,
                        F_Status: $(this.selector + '_F_Status').val()
                    };
                } else {
                    $(this.selector + '_F_DateType').val(this.arrPageFilter.F_DateType);
                    $(this.selector + '_F_StartDate').val(this.arrPageFilter.F_StartDate);
                    $(this.selector + '_F_EndDate').val(this.arrPageFilter.F_EndDate);
                    $(this.selector + '_F_Sex').val(this.arrPageFilter.F_Sex);
                    $(this.selector + '_F_LiveMode').val(this.arrPageFilter.F_LiveMode);
                    $(this.selector + '_F_IsWeekStar').val(this.arrPageFilter.F_IsWeekStar == 1);
                    $(this.selector + '_F_IsRecommend').val(this.arrPageFilter.F_IsRecommend == 1);
                    $(this.selector + '_F_Live').val(this.arrPageFilter.F_Live == 1);
                    $(this.selector + '_F_IsFamily').val(this.arrPageFilter.F_IsFamily == 1);
                    $(this.selector + '_F_Status').val(this.arrPageFilter.F_Status);
                }
                this.ofnServerParams(aoData);
            },
            'fnFooterCallback': function (nFoot, aData) {
                var _FooterData = {
                    Coin: 0,
                    Beans: 0
                };
                _.forEach(aData, function (ThisValue) {
                    _FooterData.Coin += ThisValue.Coin;
                    _FooterData.Beans += ThisValue.Beans;
                });
                $(nFoot).find('[name="Coin"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Coin / 1000)
                }).text(_FooterData.Coin);
                $(nFoot).find('[name="Beans"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金豆价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Beans / 1000)
                }).text(_FooterData.Beans);
            },
            'fnDrawCallback': function () {
                $.Common.Bootstrap.Tooltip(this);
                this.ofnDrawCallback();
            },
            'selectOpt': {
                Tools: {
                    Init: true,
                    Buttons: {
                        'btn-Anchor': {
                            text: '查看艺人信息',
                            style: 'primary',
                            addClass: 'btn disabled',
                            'data-permission-code': '{User}[Anchor](Info)',
                            action: function () {
                                $.CommonAdmin.OpenWindow(':UserAnchorInfo:' + _dtpList.selectData.User_ID, function () {
                                    _dtpList.fnDraw();
                                });
                                return false;
                            }
                        },
                        'btn-Info': {
                            text: '<i class="fa fa-search"></i> 查看用户信息',
                            style: 'primary',
                            addClass: 'btn disabled',
                            'data-permission-code': '{User}[Base](Info)',
                            action: function () {
                                $.CommonAdmin.OpenWindow(':UserInfo:' + _dtpList.selectData.User_ID, function () {
                                    _dtpList.fnDraw();
                                });
                                return false;
                            }
                        },
                        'btn-Edit': {
                            text: '<i class="fa fa-pencil"></i> 修改艺人信息',
                            style: 'primary',
                            addClass: 'btn disabled',
                            'data-permission-code': '{User}[Anchor](Edit)',
                            action: function () {
                                $.CommonAdmin.OpenWindow(':UserAnchorEdit:' + _dtpList.selectData.User_ID, function () {
                                    _dtpList.fnDraw();
                                });
                                return false;
                            }
                        },
                        'btn-Family': {
                            text: '查看公会信息',
                            style: 'primary',
                            addClass: 'btn disabled',
                            'data-permission-code': '{User}[Family](Info)',
                            action: function () {
                                $.CommonAdmin.OpenWindow(':FamilyInfo:' + _dtpList.selectData.Family_ID, function () {
                                    _dtpList.fnDraw();
                                });
                                return false;
                            }
                        },
                        'btn-Admin': {
                            text: '查看管理员信息',
                            style: 'primary',
                            addClass: 'btn disabled',
                            'data-permission-code': '{User}[Admin](Info)',
                            action: function () {
                                $.CommonAdmin.OpenWindow(':UserAdminInfo:' + _dtpList.selectData.User_ID, function () {
                                    _dtpList.fnDraw();
                                });
                                return false;
                            }
                        },
                        'btn-close': {}
                    },
                    onBuild: function (content) {
                        $.CommonAdmin.Permission.CheckElement(content);
                    },
                    onReset: function () {
                        if (!_dtpList.selectData) {
                            return;
                        }
                        var _btn = ['btn-Info', 'btn-Edit', 'btn-Anchor'];
                        if (_dtpList.selectData.IsFamily) {
                            _btn.push('btn-Family');
                        }
                        if (_dtpList.selectData.IsAdmin) {
                            _btn.push('btn-Admin');
                        }
                        _dtpList.ofnSelectToolsBtnRemoveClass(_btn);
                    }
                }
            }
        });
        //endregion
    });
</script>